define([
    "jquery",
    "IO",
    "bootbox"
], function ($, IO, bootbox) {
    $(function(){

        var year_1=1;
        var year_2=2;
        var year_3=3;

        var activity_mid=localStorage.getItem("activity_mid");

        get_capability(year_1,activity_mid);

        $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
            // 获取已激活的标签页的名称
            var activeTab = $(e.target).text();
            // 获取前一个激活的标签页的名称
            if(activeTab=="第一年度"){
                $("#year_id_hidden").val("1");
                get_capability(1,activity_mid);
            }
            else if(activeTab=="第二年度"){
                $("#year_id_hidden").val("2");

                get_capability(2,activity_mid);
            }
            else
            {
                $("#year_id_hidden").val("3");
                get_capability(3,activity_mid);
            }

        });

    });

    function get_capability(year_id,activity_mid){
        var parma={};
        parma.year_id=year_id;
        parma.activity_mid=activity_mid;

        IO.post('/shapan/api/responseCapability',parma,function(d){
            var html='';
            for(var i=1;i<= d.data.length;i++){

                html+='<div class="row1">'+
                    '<img src="/images/'+i+'p.png"><span class="name">'+d.data[i-1].group_name+'</span>'+
                    '<div style="position: relative;float:right;" class="rank'+i+'">'+'</div>'+'<span class="num" style="position: relative;float:right;left: 40px;top:3px;">'+d.data[i-1].response_capability+'</span>'+
                    '</div>';
            }
            if(year_id==1){
                $('.content').empty().append(html);
            }
            else if(year_id==2){
                $('.content2').empty().append(html);
            }
            else {
                $('.content3').empty().append(html);
            }

        });
    }
});